package com.qyer.lxp.lxdao.product.impl;

import com.qyer.lxp.common.framework.contants.QyerMethodNameContants;
import com.qyer.lxp.common.framework.convert.TransformSession;
import com.qyer.lxp.lxdao.product.IProductDao;
import com.qyer.lxp.model.product.normal.*;
import com.qyer.lxp.model.product.parameter.PickOrDropRequest;
import com.qyer.lxp.model.product.parameter.ProductCodeSearchRequest;
import com.qyer.lxp.model.product.parameter.ProductInfoRequest;
import com.qyer.lxp.model.product.parameter.SaleItemInfoRequest;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * Created by jiangping on 16/5/13.
 */

@Component
public class ProductDaoImpl implements IProductDao{

    /**
     * 获取产品code以及更新时间接口
     *
     * @param productCodeSearchRequest 获取产品信息调用参数
     * @return 返回产品信息
     * @throws Exception
     */
    public List<ProductCodeInfo> getUpdateProductInfo(ProductCodeSearchRequest productCodeSearchRequest) throws Exception {

        if(null == productCodeSearchRequest){
            return null;
        }
        List<ProductCodeInfo> productCodeInfoList = null;
        ProductCodeInfos productCodeInfos = (ProductCodeInfos) TransformSession.selectOne(QyerMethodNameContants.LX_METHOD_NAME_GETUPDATEPRODUCTINFO,productCodeSearchRequest, QyerMethodNameContants.LX_CLASS_NAME_PRODUCTCODEINFOS);
        if(null != productCodeInfos){
            productCodeInfoList = productCodeInfos.getProductCodeInfoList();
        }
        return productCodeInfoList;
    }

    /**
     * 获取产品详细信息
     *
     * @param productInfoRequest 获取产品信息调用参数
     * @return 返回产品信息
     * @throws Exception
     */
    public ProductInfo getProductInfo(ProductInfoRequest productInfoRequest) throws Exception {

        if(null == productInfoRequest){
            return null;
        }
        ProductInfo productInfo = (ProductInfo) TransformSession.selectOne(QyerMethodNameContants.LX_METHOD_NAME_GETPRODUCTDETAIL,productInfoRequest, QyerMethodNameContants.LX_CLASS_NAME_PRODUCTINFO);
        return productInfo;
    }

    /**
     * 获取接送信息接口
     *
     * @param pickOrDropRequest 获取接机信息调用参数
     * @return 返回接机对象
     * @throws Exception
     */
    @Override
    public List<ProductPickInfo> getPickOrDrop(PickOrDropRequest pickOrDropRequest) throws Exception {
        List<ProductPickInfo> productPickInfoList = null;
        ProductPickInfos productPickInfos = (ProductPickInfos) TransformSession.selectOne(QyerMethodNameContants.LX_METHOD_NAME_GETPICKORDROP,pickOrDropRequest, QyerMethodNameContants.LX_CLASS_NAME_PRODUCTPICKINFOS);
        if(null != productPickInfos){
            productPickInfoList = productPickInfos.getProductPickInfos();
        }
        return productPickInfoList;
    }

    /**
     * 销售项目基本信息接口
     *
     * @param saleItemInfoRequest 请求参数
     * @return 返回销售基本信息对象
     * @throws Exception
     */
    @Override
    public List<SaleItemInfo> getSaleItemInfo(SaleItemInfoRequest saleItemInfoRequest) throws Exception {
        List<SaleItemInfo> saleItemInfoList = null;
        SaleItemInfoList saleItemInfos = (SaleItemInfoList) TransformSession.selectExtraOne(QyerMethodNameContants.LX_METHOD_NAME_GETSALEITEMINFO,saleItemInfoRequest, QyerMethodNameContants.LX_CLASS_NAME_SALEITEMINFOS);
        if(null != saleItemInfos){
            saleItemInfoList = saleItemInfos.getSaleItemInfoList();
        }
        return saleItemInfoList;
    }


}
